package com.xy.manage.service.impl;


import java.util.List;
import java.util.Map;
import java.util.Date;
import com.xy.core.util.BeanUtil;
import com.xy.common.page.Pagination;
import com.xy.core.service.impl.BaseServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.xy.manage.dao.TresidenceDao;
import com.xy.manage.model.Tresidence;
import com.xy.manage.service.TresidenceService;

@Service
@Transactional
public class TresidenceServiceImpl extends BaseServiceImpl<Tresidence> implements
		TresidenceService {
	private TresidenceDao tresidenceDao;

	public TresidenceServiceImpl(TresidenceDao paramAppRoleDao) {
		super(paramAppRoleDao);
		this.tresidenceDao = paramAppRoleDao;
	}

	@Override
	public boolean checkExist(String paraName, String paraValue) {
		return tresidenceDao.checkExist("Tresidence", paraName, paraValue);
	}

	@Override
	public List<Tresidence> getTresidence(Map<String, Object> map) {
		return tresidenceDao.getTresidence(map);
	}
	@Override
	public Pagination getTresidenceByPage(Map<String, Object> map, int pageNo,
			int pageSize) {
		// TODO Auto-generated method stub
		return tresidenceDao.getTresidenceByPage(map, pageNo, pageSize);
	}
	 
   @Override
	public Tresidence save(Tresidence tresidence) {
	//	tresidence.setModtime(new Date());
		if(tresidence.getResidenceid()==null){
			//新增
        	return super.save(tresidence);
		}else{
			//更新
			Tresidence tresidence1=tresidenceDao.get(tresidence.getResidenceid());
			try {
				BeanUtil.copyNotNullProperties(tresidence1, tresidence);
			} catch (Exception e) {
				e.printStackTrace();
			}  
			return super.save(tresidence1);
		}
	}
}